﻿using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Reflection;
using System.Text;
using System.Windows.Forms;

namespace FtpWorkSession2
{
    public partial class Form1 : Form
    {
        private const string url = "169.254.136.88";
        private const string log = "admin";
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            FTPWorks ftp = new FTPWorks();
            ftp.ShowStatus += AddStatus;
            
            ftp.OpenConnection(url, 21, log, log);
            ftp.GetFileFromFtp("out/Debts.xml", Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase) + @"\Import\Debts.xml", true);
            ftp.CloseConnection();
        }

        private void AddStatus (string s, bool b)
        {
            listBox1.Items.Add(s);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            FTPWorks ftp = new FTPWorks();
            ftp.ShowStatus += AddStatus;

            ftp.OpenConnection(url, 21, log, log);
            ftp.FtpPutFile("in/Debts.xml", Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase) + @"\Import\Debts.xml", true);
            ftp.CloseConnection();

        }
    }
}